#!/usr/bin/env bash
# encoding: utf-8.0

MAVEN_REPO_DIR="/lyndon/iProject/maven-repo"

joinByChar() {
  local IFS="$1"
  shift
  echo "$*"
}

while read srcline
do
  find $MAVEN_REPO_DIR -name "$srcline" | while read resline; do
     resname=$(echo $resline | sed 's%/lyndon/iProject/maven-repo/%%')
     # echo ${resname}
     IFS='/' read -r -a array <<< "$resname"
     filename=${array[-1]};
     unset array[-1]
     version=${array[-1]};
     unset array[-1]
     arti=${array[-1]};
     unset array[-1]
     groupId=$(joinByChar '.' ${array[@]})
     echo "mvn install:install-file -Dfile=target/lib/${filename} -DgroupId=${groupId} -DartifactId=${arti} -Dversion=${version} -Dpackaging=jar"
  done
done < $1
